{extend name="base" /} {block name="body"}
<div class="layui-body">
	<div class="navbar">
		<a><cite>商城管理</cite></a>&nbsp;<span class="layui-box">&gt;</span>

	</div>
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<form class="layui-form layui-form-pane" action="" method="post">
			<blockquote class="layui-elem-quote">
				<div class="layui-inline">
					<div class="layui-input-inline">
						<input type="text" name="name" placeholder="商品名称" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<select name="is_on_sale">
						<option value="0">状态</option>
						<option value="1" {if $is_on_sale=='1' }selected{/if}>上架</option>
						<option value="2" {if $is_on_sale=='2' }selected{/if}>下架</option>
					</select>
				</div>
				<button class="layui-btn search_btn"><i class="fa fa-search"></i> 查询</a>
			<!--<a class="layui-btn layui-btn-status page-btns" href="{:url('status',['table'=>'goods','val'=>1,'id_name'=>'goods_id','field'=>'is_on_sale'])}"><i class="fa fa-check-circle-o"></i> 上架</a>
			<a class="layui-btn layui-btn-danger page-btns" href="{:url('status',['table'=>'goods','val'=>2,'id_name'=>'goods_id','field'=>'is_on_sale'])}"><i class="fa fa-ban"></i> 下架</a>-->
		</blockquote>
		</form>
		<div >
			<a class="layui-btn  layui-btn-normal" href='add'>添加商品</a>
		</div>
		<div class="layui-tab-content">
			<table class="layui-table layui-form">
				<thead>
					<tr>
						<th style="width: 30px;">
							<input type="checkbox" lay-skin="primary" lay-filter="allChoose">
						</th>
						<th class="text-center">图片</th>
                        <th class="text-center">商品编号</th>
                        <th class="text-center">商品名称</th>
                        <th class="text-center">销售价</th>
                        <th class="text-center">累计销售</th>
                        <th class="text-center">上下架状态</th>
                        <th class="text-center">添加时间</th>
                        <th class='text-center'>操作</th>
					</tr>
				</thead>
				<tbody>
					<form id="listForm">
						{foreach name="list" item="vo"}
						<tr>
							<td>
								<input type="checkbox" name="ids[]" value="{$vo.id}" class="layui-checkbox checkbox-ids" lay-skin="primary">
							</td>
							<td><img style="width: 40px; height: 40px;" src="{$vo.thumb}"/></td>
							<td>{$vo.sn}</td>
							<td>{$vo.name}</td>
							<td>{$vo.money}</td>
							<td>{$vo.sales}</td>
							<td>{$vo.is_on_sale==1?'上架':'下架'}</td>
							<td>{$vo.add_time}</td>
							<td>  
								<a href="update?id={$vo.id}" class="layui-btn layui-btn-small"><i class="fa fa-edit"></i> 编辑</a>
								<a  onclick='del({$vo.id})' class="layui-btn  layui-btn-error layui-btn-small">删除</a>
						</tr>
						{/foreach}
					</form>
				</tbody>
			</table>
			{$list->render()}
		</div>
	</div>
</div>
{/block}
{block name="js"}
<script>
	function del(obj) {
		layer.confirm('确定要删除吗？', {
			btn: ['确认', '取消'],
		}, function(index) {
			$.ajax({
				type: "post",
				url: "{:url('shop/delete')}",
				data: {id: obj}, //表单数据
				success: function(data) {
					layer.msg(data.msg, function(index) {
						location.href = data.url;

					});

				}
			});

		});

	}
</script>
{/block}